import {defineStore} from 'pinia'
import {getApiList} from "@/serve";
import type {AreaTree, ChinaAdd, ChinaTotal, RootObject, StatisGradeCityDetail} from "@/stores/type";

export const useCounterStore = defineStore({
	id: 'counter',
	state: () => ({
		list: <RootObject>{},
		item: <AreaTree[]>[],
		chinaAdd: <ChinaAdd>{},
		chinaTotal: <ChinaTotal>{},
		cityDetail: <StatisGradeCityDetail[]>[]
	}),
	actions: {
		async getList() {
			const result = await getApiList();
			this.list = result;
			this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd
			this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal
			this.cityDetail = this.list.statisGradeCityDetail.splice(0, 10)  // 截取前10条数据
		}
	}
})
